﻿using System;
using System.Runtime.InteropServices;

namespace FutureTech.Media.ComputerVision
{
        public class BitmapImage
        {
                protected BitmapImage(int width, int height, BitsWide bitsWide)
                {
                        Width = width;
                        Height = height;

                        BitsWide = bitsWide;

                        PixelBufferBytesCount = Width*Height*(int)BitsWide/8;

                        PixelBufferPtr = Marshal.AllocHGlobal(PixelBufferBytesCount);
                }

                #region 属性

                /// <summary>
                /// 横向分辨率
                /// </summary>
                public int Width { get; private set; }

                /// <summary>
                /// 纵向分辨率
                /// </summary>
                public int Height { get; private set; }

                /// <summary>
                /// 采集位宽
                /// </summary>
                public BitsWide BitsWide { get; private set; }

                /// <summary>
                /// 像素缓冲区指针
                /// </summary>
                public IntPtr PixelBufferPtr { get; private set; }

                /// <summary>
                /// 像素缓冲区字节计数
                /// </summary>
                public int PixelBufferBytesCount { get; private set; }

                /// <summary>
                /// 像素缓冲区行宽
                /// </summary>
                public uint PixelBufferStride
                {
                        get { return (uint) (Width*(int) BitsWide/8); }
                }

                #endregion

        }
}
